/* 
 * File:   main.cpp
 * Author: Lucky
 *
 * Created on 21. září 2011, 16:25
 */

#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <time.h>

#include <iostream>
#include <fstream>
#include "Coordinate.h"
#include "Library.h"
#include "Chessboard.h"
#include "Solver.h"
#include "Field.h"
#include "FieldSolver.h"

using namespace std;

/*
 * 
 */
int main(int argc, char** argv) {
    int width; //board width
    int height; //board height
    int q; //number of lit lights
    int* coords; //corrdinates array

    string filename=""; 
    if (true) 
    {
        coords =  Library::LoadDataFromFile(filename,&width,&height,&q);
           cout <<"Sirka "<<width<<" vyska: "<<height<<" pocet souradnic: "<<q<<endl;
    } else {
        width = Library::LoadInt("Zadejte sirku pole: ", 3, INT_MAX);
        height = Library::LoadInt("Zadejte vysku pole: ", 3, INT_MAX);
        q = Library::LoadInt("Zadejte pocet rozsvicenych svetel: ", 1, width * height);

        coords = Library::LoadCoordinates(q, width, height);
    }
    cout << coords[0]<<"   "<< coords[1] << endl;
    Chessboard* board = new Chessboard(width, height, coords, q);
    cout << "pocet svetel: " << board->getOnLightsCount() << endl;

    cout << "m: " << width << endl;
    cout << "n: " << height << endl;
    cout << "q: " << q << endl;

//    LightStack* stack = new LightStack();
//    stack->push(new Node(0, 0, SWITCH));
//    stack->push(new Node(0, 0, LEAVE));
//
//
//    Solver s(board, stack);
//    time_t t1;
//    time(&t1);
//    cout << "Solver zavolan " << endl;
//    s.compute();
//    time_t t2;
//    time(&t2);
//    cout << "Doba reseni " << t2 - t1 << " sekund" << endl;
    
    Field* field = new Field(width * height);
    FieldSolver solver(width, height, q, coords, field);
    solver.compute();
    
    
    delete coords;


#ifdef _WIN32
    system("pause");
#endif
    return 0;
}

